package com.dream.technology.mockTest;

import com.dream.technology.controller.RcFieldController;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.http.MediaType;
import org.springframework.test.context.ActiveProfiles;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.result.MockMvcResultHandlers;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

/**
 * 描述：
 *
 * @author chen_q_i@163.com
 * 2019/2/27 : 14:13.
 * @version : 1.0
 */
@ActiveProfiles("dev")
@RunWith(SpringRunner.class)
@SpringBootTest
public class FieldContrlT {



    @Autowired
    private RcFieldController rcFieldController;

    private MockMvc mvc;

    @Before
    public void setup(){
        mvc = MockMvcBuilders.standaloneSetup(rcFieldController).build();
    }


    @Test
    public void exampleTest() throws Exception {
        this.mvc.perform(get("/risk/admin/field/getFieldByCode").accept(MediaType.APPLICATION_JSON)
                .param("fieldCode","moXieGraySever.gray_info_detail.gray_types")).andExpect(status().isOk())
                .andDo(MockMvcResultHandlers.print());
    }

    @Test
    public void getMoxieBlackListTypes() throws Exception {
        this.mvc.perform(get("/risk/admin/field/getFieldByCode").accept(MediaType.APPLICATION_JSON)
                .param("fieldCode","moXieGraySever.black_info_detail.black_types")).andExpect(status().isOk())
                .andDo(MockMvcResultHandlers.print());
    }
}
